package com.example.oauth.controller;

import jakarta.servlet.http.HttpServletResponse;

import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.swing.plaf.PanelUI;
import java.io.IOException;

@Controller
public class UserController {

    @RequestMapping("/")
    public String index() {
        return "index";
    }

    //成功登陆,其实就是给的json数据，返回了写好的值而已，并不是返回的一个视图
    @RequestMapping("/successLogin")
    @ResponseBody
    public String successLogin(OAuth2AuthenticationToken token) throws IOException {
        System.out.println(token);
        return ("欢迎你gitee用户" + token.getPrincipal().getAttributes().get("login"));
    }
}
